Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

libnpmpublish

Package Overview
Dependencies
Maintainers
9
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

libnpmpublish

Programmatic API for the bits behind npm publish and unpublish

  • 1.1.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1M
decreased by-40.6%
Maintainers
9
Weekly downloads
 
Created

What is libnpmpublish?

The libnpmpublish package is a library for programmatically publishing npm packages. It provides a set of functions to handle the publishing process, including authentication, package validation, and publishing to the npm registry.

What are libnpmpublish's main functionalities?

Authentication

This feature allows you to authenticate with the npm registry using your credentials. The code sample demonstrates how to use the `getAuth` function from the `libnpm` package to obtain authentication details.

const libnpmpublish = require('libnpmpublish');
const { getAuth } = require('libnpm');

async function authenticate() {
  const auth = await getAuth({
    scope: '@my-scope',
    registry: 'https://registry.npmjs.org/'
  });
  return auth;
}
authenticate().then(auth => console.log(auth));

Package Validation

This feature allows you to validate your package before publishing it. The code sample demonstrates how to read a `package.json` file and validate its contents using the `validate` function from `libnpmpublish`.

const libnpmpublish = require('libnpmpublish');
const fs = require('fs');

async function validatePackage() {
  const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
  const validation = await libnpmpublish.validate(pkg);
  console.log(validation);
}
validatePackage();

Publishing

This feature allows you to publish your npm package to the registry. The code sample demonstrates how to read a `package.json` file and a tarball file, and then publish the package using the `publish` function from `libnpmpublish`.

const libnpmpublish = require('libnpmpublish');
const fs = require('fs');

async function publishPackage() {
  const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
  const tarballData = fs.readFileSync('package.tgz');
  const auth = { token: 'your-npm-token' };
  await libnpmpublish.publish(pkg, tarballData, auth);
  console.log('Package published successfully');
}
publishPackage();

Other packages similar to libnpmpublish

FAQs

Package last updated on 18 Sep 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc